#include <windows.h>
#include <stdio.h>

int main() {
    DISPLAY_DEVICEA dd;
    dd.cb = sizeof(dd);
    DWORD deviceNum = 0;

    while (EnumDisplayDevicesA(NULL, deviceNum, &dd, 0)) {
        printf("Display Device %d:\n", deviceNum);
        printf("  Device Name  : %s\n", dd.DeviceName);
        printf("  Device String: %s\n", dd.DeviceString);
        printf("  State Flags  : 0x%08x\n", dd.StateFlags);

        if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
            printf("    -> Primary Display\n");
        if (dd.StateFlags & DISPLAY_DEVICE_ACTIVE)
            printf("    -> Active\n");

        // 获取与该显卡关联的监视器信息
        DISPLAY_DEVICEA ddMon;
        ZeroMemory(&ddMon, sizeof(ddMon));
        ddMon.cb = sizeof(ddMon);
        DWORD monitorNum = 0;

        while (EnumDisplayDevicesA(dd.DeviceName, monitorNum, &ddMon, 0)) {
            printf("    Monitor %d:\n", monitorNum);
            printf("      Device Name  : %s\n", ddMon.DeviceName);
            printf("      Device String: %s\n", ddMon.DeviceString);
            printf("      State Flags  : 0x%08x\n", ddMon.StateFlags);
            monitorNum++;
        }

        deviceNum++;
    }

    return 0;
}
